import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRouterMap = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: '/dashboard/dashboard'
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/dashboard',
    component: Layout,
    meta: { title: '首页', icon: 'dashboard' },
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/dashboard'),
        meta: { title: '首页', icon: 'dashboard', keepAlive: true }
      }
    ]
  },
  {
    path: '',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/newPwd',
        name: 'newPwd',
        component: () => import('@/views/login/newPwd'),
        meta: { title: '修改密码', keepAlive: true }
      }
    ]
  },

]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/reading',
    component: Layout,
    redirect: '/reading/index',
    name: 'reading',
    meta: {
      title: '工程项目管理',
      icon: 'el-icon-s-help',
    },
    children: [
      {
        path: 'index',
        name: 'index',
        component: () => import('@/views/reading/index'),
        meta: {title: '工程项目管理',icon: 'el-icon-s-help',perms: [1],keepAlive: true},
      }, {
        path: 'projectUpeate/:id',
        name: 'projectUpeate',
        component: () => import('@/views/reading/projectUpeate'),
        meta: {title: '工程立项',perms: [1],keepAlive: false},
        hidden: true
      },{
        path: 'quality/:id',
        name: 'quality',
        component: () => import('@/views/reading/quality'),
        meta: {title: '建设质量控制',perms: [1],keepAlive: false},
        hidden: true
      }, {
        path: 'pay/:id',
        name: 'pay',
        component: () => import('@/views/reading/pay'),
        meta: {title: '项目付款',perms: [1],keepAlive: false},
        hidden: true
      }
    ]
  },
  {
    path: '/purchase',
    component: Layout,
    redirect: '/purchase/purchaseList',
    name: 'purchase',
    meta: {
      title: '政府采购管理',
      icon: 'purchase'
    },
    children: [
      {
        path: 'purchaseList',
        name: 'purchaseList',
        component: () => import('@/views/purchase/purchaseList'),
        meta: {title: '政府采购管理',icon: 'purchase',perms: [1],keepAlive: true},
      }, {
        path: 'product/:id',
        name: 'product',
        component: () => import('@/views/purchase/product'),
        meta: {title: '采购项目立项',perms: [1],keepAlive: false},
        hidden: true
      }
    ]
  },
 /* {
    path: '/products',
    component: Layout,
    name: 'products',
    redirect: '/supervision/productDetail',
    meta: {title: '资产、资源管理',icon: 'property'},
    children: [
      {
        path: 'productDetail/:id',
        name: 'productDetail',
        component: () => import('@/views/supervision/productDetail'),
        meta: {title: '资产、资源管理',icon: 'property',perms: [3],keepAlive: true},
        hidden: true
      }
    ]
  },*/
  {
    path: '/resource',
    component: Layout,
    redirect: '/resource/resourceList',
    name: 'resource',
    meta: {
      title: '资产、资源管理',
      icon: 'property'
    },
    children: [
      {
        path: 'resourceList',
        name: 'resourceList',
        component: () => import('@/views/resource/resourceList'),
        meta: {title: '资产、资源管理',perms: [1],keepAlive: true},
      },{
        path: 'resourceDetail/:id',
        name: 'resourceDetail',
        component: () => import('@/views/resource/resourceDetail'),
        meta: {title: '资产/资源详情',perms: [1],keepAlive: false},
        hidden: true
      },{
        path: 'contract',
        name: 'contract',
        component: () => import('@/views/resource/contract'),
        meta: {title: '非招投标出租合同',perms: [1],keepAlive: true}
      }
    ]
  },
  {
    path: '/rectification',
    component: Layout,
    redirect: '/rectification/index',
    name: 'rectification',
    meta: {
      title: '整改单查询',
      icon: 'security'
    },
    children: [
      {
        path: 'single',
        name: 'single',
        component: () => import('@/views/rectification/single'),
        meta: {title: '整改单查询处理',icon: 'security',perms: [1],keepAlive: true},
      }
    ]
  },
  {
    path: '/supervision',
    component: Layout,
    redirect: '/supervision/projectList',
    name: 'supervision',
    meta: {
      title: '工程项目监督',
      icon: 'project'
    },
    children: [
      {
        path: 'projectList',
        name: 'projectList',
        component: () => import('@/views/supervision/projectList'),
        meta: {title: '工程项目查询',perms: [3],keepAlive: true},
      }, {
        path: 'record',
        name: 'record',
        component: () => import('@/views/supervision/record'),
        meta: {title: '监督检查记录',perms: [3],keepAlive: true},
      },{
        path: 'projectSingle',
        name: 'projectSingle',
        component: () => import('@/views/supervision/projectSingle'),
        meta: {title: '项目整改单',perms: [3],keepAlive: true},
      },{
        path: 'renewAndRollback',
        name: 'renewAndRollback',
        component: () => import('@/views/supervision/renewAndRollback'),
        meta: {title: '项目恢复或回退',perms: [3],keepAlive: true},
      },{
        path: 'productDetail/:id',
        name: 'productDetail',
        component: () => import('@/views/supervision/productDetail'),
        meta: {title: '详情',icon: 'property',perms: [3],keepAlive: true},
        hidden: true
      }
    ]
  },
  {
    path: '/procurement',
    component: Layout,
    redirect: '/procurement/purchasePro',
    name: 'procurement',
    meta: {
      title: '政府采购监督',
      icon: 'procurement'
    },
    children: [
      {
        path: 'purchasePro',
        name: 'purchasePro',
        component: () => import('@/views/procurement/purchasePro'),
        meta: {title: '采购项目查询',perms: [3],keepAlive: true},
      }, {
        path: 'examine',
        name: 'examine',
        component: () => import('@/views/procurement/examine'),
        meta: {title: '监督检查记录',perms: [3],keepAlive: true},
      },{
        path: 'punchLists',
        name: 'punchLists',
        component: () => import('@/views/procurement/punchLists'),
        meta: {title: '采购项目整改单',perms: [3],keepAlive: true},
      },{
        path: 'abarbeitung',
        name: 'abarbeitung',
        component: () => import('@/views/procurement/abarbeitung'),
        meta: {title: '采购项目恢复或整改',perms: [3],keepAlive: true},
      }
    ]
  },
  {
    path: '/bidding',
    component: Layout,
    redirect: '/bidding/bidList',
    name: 'bidding',
    meta: {
      title: '公共资产招投标监督',
      icon: 'property'
    },
    children: [
      {
        path: 'bidList',
        name: 'bidList',
        component: () => import('@/views/bidding/bidList'),
        meta: {title: '招投标项目查询',perms: [3],keepAlive: true},
      }, {
        path: 'bidInspect',
        name: 'bidInspect',
        component: () => import('@/views/bidding/bidInspect'),
        meta: {title: '监督检查记录',perms: [3],keepAlive: true},
      },{
        path: 'bidAbarbeitung',
        name: 'bidAbarbeitung',
        component: () => import('@/views/bidding/bidAbarbeitung'),
        meta: {title: '招投标项目整改单',perms: [3],keepAlive: true},
      },{
        path: 'bidRecover',
        name: 'bidRecover',
        component: () => import('@/views/bidding/bidRecover'),
        meta: {title: '招投标项目恢复或整改',perms: [3],keepAlive: true},
      }
    ]
  },
  {
    path: '/projectApproval',
    component: Layout,
    redirect: '/projectApproval/projectExamine',
    name: 'projectApproval',
    meta: {
      title: '工程项目审批',
      icon: 'el-icon-s-help'
    },
    children:[
      {
        path: 'projectExamine',
        name: 'projectExamine',
        component: () => import('@/views/projectApproval/projectExamine'),
        meta: {title: '工程立项审批',perms: [2],keepAlive: true},
      }, {
        path: 'tenderExamine',
        name: 'tenderExamine',
        component: () => import('@/views/projectApproval/tenderExamine'),
        meta: {title: '项目招标审批',perms: [2],keepAlive: true},
      }, {
        path: 'startsExamine',
        name: 'startsExamine',
        component: () => import('@/views/projectApproval/startsExamine'),
        meta: {title: '项目建设开工审批',perms: [2],keepAlive: true},
      }, {
        path: 'acceptance',
        name: 'acceptance',
        component: () => import('@/views/projectApproval/acceptance'),
        meta: {title: '工程验收审批',perms: [2],keepAlive: true},
      }, {
        path: 'projectPay',
        name: 'projectPay',
        component: () => import('@/views/projectApproval/projectPay'),
        meta: {title: '项目付款审批',perms: [2],keepAlive: true},
      }
    ]
  },
  {
    path: '/proApproval',
    component: Layout,
    redirect: '/proApproval/approvalIndex',
    name: 'proApproval',
    meta: {
      title: '政府采购审批',
      icon: 'procurement'
    },
    children:[
      {
        path: 'approvalIndex',
        name: 'approvalIndex',
        component: () => import('@/views/proApproval/approvalIndex'),
        meta: {title: '采购立项审批',perms: [2],keepAlive: true},
      }, {
        path: 'proTender',
        name: 'proTender',
        component: () => import('@/views/proApproval/proTender'),
        meta: {title: '招标审批',perms: [2],keepAlive: true},
      }, {
        path: 'proPayment',
        name: 'proPayment',
        component: () => import('@/views/proApproval/proPayment'),
        meta: {title: '项目付款审批',perms: [2],keepAlive: true},
      },{
        path: 'productDetail/:id',
        name: 'productDetail',
        component: () => import('@/views/supervision/productDetail'),
        meta: {title: '详情',icon: 'property',perms: [2],keepAlive: true},
        hidden: true
      }
    ]
  },
  {
    path: '/assetExamine',
    component: Layout,
    redirect: '/assetExamine/index',
    name: 'assetExamine',
    meta: {
      title: '公共资产、资源出租招标审批',
      icon: 'property'
    },
    children: [
      {
        path: 'assetIndex',
        name: 'assetIndex',
        component: () => import('@/views/assetExamine/index'),
        meta: {title: '资产/资源出租招标审批',icon: 'el-icon-s-check',perms: [2],keepAlive: true},
      },
    ]
  },
  {
    path: '/authority',
    component: Layout,
    redirect: '/authority/user',
    name: 'authority',
    meta: {
      title: '权限管理',
      icon: 'peoples'
    },
    children: [{
      path: 'user',
      name: 'user',
      component: () => import('@/views/authority/user'),
      meta: {title: '用户管理',perms: [0], keepAlive: true}
    }, {
      path: 'role',
      name: 'role',
      component: () => import('@/views/authority/role'),
      meta: {title: '角色管理',perms: [0], keepAlive: true}
    }, {
      path: 'org',
      name: 'org',
      component: () => import('@/views/authority/org'),
      meta: {title: '机构管理',perms: [0], keepAlive: true}
    },
    //   {
    //   path: 'policy',
    //   name: 'policy',
    //   component: () => import('@/views/authority/policy'),
    //   meta: {title: '三项交易政策法规',perms: [0], keepAlive: true}
    // }
      /*{
      path: 'menu',
      name: 'menu',
      component: () => import('@/views/authority/menu'),
      meta: {title: '菜单管理',perms: [0], keepAlive: true},
      hidden: true
    }*/
    ]
  },
  {
    path: '/regulations',
    component: Layout,
    redirect: '/regulations/policy',
    name: 'regulations',
    meta: {
      title: '三项交易政策法规',
      icon: 'policy'
    },
    children: [
      {
        path: 'policy',
        name: 'policy',
        component: () => import('@/views/regulations/policy'),
        meta: {title: '三项交易政策法规',icon: 'policy',perms: [0,1,2],keepAlive: true},
      }
    ]
  },
  {
    path: '/config',
    component: Layout,
    redirect: '/system/config',
    name: 'config2',
    meta: {
      title: '系统管理',
      icon: 'el-icon-s-tools'
    },
    children: [
    //   {
    //   path: 'config',
    //   name: 'config',
    //   component: () => import('@/views/system/config'),
    //   meta: {title: '系统配置',perms: [1], icon: 'el-icon-s-tools', keepAlive: true}
    // },
      {
      path: 'system',
      name: 'system',
      component: () => import('@/views/system/system'),
      meta: {title: '系统日志查询',perms: [4], icon: 'el-icon-s-order', keepAlive: true}
    }]
  },
  { path: '*', redirect: '/404', hidden: true }
  ]

// export default router
